/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('aegis', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateInstanceRequest {
  autoRenewDuration?: int32(name='AutoRenewDuration'),
  clientToken?: string(name='ClientToken'),
  duration?: int32(name='Duration'),
  isAutoRenew?: boolean(name='IsAutoRenew'),
  ownerId?: long(name='OwnerId'),
  pricingCycle?: string(name='PricingCycle'),
  versionCode?: int32(name='VersionCode'),
  vmNumber?: int32(name='VmNumber'),
}

model CreateInstanceResponseBody = {
  instanceId?: string(name='InstanceId'),
  orderId?: string(name='OrderId'),
  requestId?: string(name='RequestId'),
}

model CreateInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateInstanceResponseBody(name='body'),
}

async function createInstanceWithOptions(request: CreateInstanceRequest, runtime: Util.RuntimeOptions): CreateInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.autoRenewDuration)) {
    query['AutoRenewDuration'] = request.autoRenewDuration;
  }
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.duration)) {
    query['Duration'] = request.duration;
  }
  if (!Util.isUnset(request.isAutoRenew)) {
    query['IsAutoRenew'] = request.isAutoRenew;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.pricingCycle)) {
    query['PricingCycle'] = request.pricingCycle;
  }
  if (!Util.isUnset(request.versionCode)) {
    query['VersionCode'] = request.versionCode;
  }
  if (!Util.isUnset(request.vmNumber)) {
    query['VmNumber'] = request.vmNumber;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateInstance',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createInstance(request: CreateInstanceRequest): CreateInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return createInstanceWithOptions(request, runtime);
}

model DeleteRuleRequest {
  id?: string(name='Id'),
  lang?: string(name='Lang'),
  sourceIp?: string(name='SourceIp'),
}

model DeleteRuleResponseBody = {
  requestId?: string(name='RequestId'),
}

model DeleteRuleResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteRuleResponseBody(name='body'),
}

async function deleteRuleWithOptions(request: DeleteRuleRequest, runtime: Util.RuntimeOptions): DeleteRuleResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.id)) {
    query['Id'] = request.id;
  }
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteRule',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteRule(request: DeleteRuleRequest): DeleteRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteRuleWithOptions(request, runtime);
}

model DescribeAutoDelConfigRequest {
  sourceIp?: string(name='SourceIp'),
}

model DescribeAutoDelConfigResponseBody = {
  days?: int32(name='Days'),
  requestId?: string(name='RequestId'),
}

model DescribeAutoDelConfigResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeAutoDelConfigResponseBody(name='body'),
}

async function describeAutoDelConfigWithOptions(request: DescribeAutoDelConfigRequest, runtime: Util.RuntimeOptions): DescribeAutoDelConfigResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeAutoDelConfig',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeAutoDelConfig(request: DescribeAutoDelConfigRequest): DescribeAutoDelConfigResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeAutoDelConfigWithOptions(request, runtime);
}

model DescribeCheckWarningDetailRequest {
  checkWarningId?: long(name='CheckWarningId'),
  lang?: string(name='Lang'),
  sourceIp?: string(name='SourceIp'),
}

model DescribeCheckWarningDetailResponseBody = {
  advice?: string(name='Advice'),
  checkId?: long(name='CheckId'),
  description?: string(name='Description'),
  item?: string(name='Item'),
  level?: string(name='Level'),
  prompt?: string(name='Prompt'),
  requestId?: string(name='RequestId'),
  type?: string(name='Type'),
}

model DescribeCheckWarningDetailResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeCheckWarningDetailResponseBody(name='body'),
}

async function describeCheckWarningDetailWithOptions(request: DescribeCheckWarningDetailRequest, runtime: Util.RuntimeOptions): DescribeCheckWarningDetailResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.checkWarningId)) {
    query['CheckWarningId'] = request.checkWarningId;
  }
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeCheckWarningDetail',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeCheckWarningDetail(request: DescribeCheckWarningDetailRequest): DescribeCheckWarningDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeCheckWarningDetailWithOptions(request, runtime);
}

model DescribeConcernNecessityRequest {
  lang?: string(name='Lang'),
  sourceIp?: string(name='SourceIp'),
}

model DescribeConcernNecessityResponseBody = {
  concernNecessity?: [ string ](name='ConcernNecessity'),
  requestId?: string(name='RequestId'),
}

model DescribeConcernNecessityResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeConcernNecessityResponseBody(name='body'),
}

async function describeConcernNecessityWithOptions(request: DescribeConcernNecessityRequest, runtime: Util.RuntimeOptions): DescribeConcernNecessityResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeConcernNecessity',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeConcernNecessity(request: DescribeConcernNecessityRequest): DescribeConcernNecessityResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeConcernNecessityWithOptions(request, runtime);
}

model DescribeInstanceStatisticsRequest {
  lang?: string(name='Lang'),
  sourceIp?: string(name='SourceIp'),
  uuid?: string(name='Uuid'),
}

model DescribeInstanceStatisticsResponseBody = {
  data?: [ 
    {
      account?: int32(name='Account'),
      health?: int32(name='Health'),
      suspicious?: int32(name='Suspicious'),
      trojan?: int32(name='Trojan'),
      uuid?: string(name='Uuid'),
      vul?: int32(name='Vul'),
    }
  ](name='Data'),
  requestId?: string(name='RequestId'),
}

model DescribeInstanceStatisticsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeInstanceStatisticsResponseBody(name='body'),
}

async function describeInstanceStatisticsWithOptions(request: DescribeInstanceStatisticsRequest, runtime: Util.RuntimeOptions): DescribeInstanceStatisticsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  if (!Util.isUnset(request.uuid)) {
    query['Uuid'] = request.uuid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeInstanceStatistics',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeInstanceStatistics(request: DescribeInstanceStatisticsRequest): DescribeInstanceStatisticsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeInstanceStatisticsWithOptions(request, runtime);
}

model DescribeStrategyExecDetailRequest {
  sourceIp?: string(name='SourceIp'),
  strategyId?: int32(name='StrategyId'),
}

model DescribeStrategyExecDetailResponseBody = {
  endTime?: string(name='EndTime'),
  failCount?: int32(name='FailCount'),
  failedEcsList?: [ 
    {
      IP?: string(name='IP'),
      instanceName?: string(name='InstanceName'),
      internetIp?: string(name='InternetIp'),
      intranetIp?: string(name='IntranetIp'),
      reason?: string(name='Reason'),
    }
  ](name='FailedEcsList'),
  inProcessCount?: int32(name='InProcessCount'),
  percent?: string(name='Percent'),
  requestId?: string(name='RequestId'),
  source?: string(name='Source'),
  startTime?: string(name='StartTime'),
  successCount?: int32(name='SuccessCount'),
}

model DescribeStrategyExecDetailResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeStrategyExecDetailResponseBody(name='body'),
}

async function describeStrategyExecDetailWithOptions(request: DescribeStrategyExecDetailRequest, runtime: Util.RuntimeOptions): DescribeStrategyExecDetailResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  if (!Util.isUnset(request.strategyId)) {
    query['StrategyId'] = request.strategyId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeStrategyExecDetail',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeStrategyExecDetail(request: DescribeStrategyExecDetailRequest): DescribeStrategyExecDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeStrategyExecDetailWithOptions(request, runtime);
}

model DescribeVulWhitelistRequest {
  currentPage?: int32(name='CurrentPage'),
  pageSize?: int32(name='PageSize'),
  sourceIp?: string(name='SourceIp'),
}

model DescribeVulWhitelistResponseBody = {
  currentPage?: int32(name='CurrentPage'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  totalCount?: int32(name='TotalCount'),
  vulWhitelists?: [ 
    {
      aliasName?: string(name='AliasName'),
      name?: string(name='Name'),
      reason?: string(name='Reason'),
      type?: string(name='Type'),
    }
  ](name='VulWhitelists'),
}

model DescribeVulWhitelistResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeVulWhitelistResponseBody(name='body'),
}

async function describeVulWhitelistWithOptions(request: DescribeVulWhitelistRequest, runtime: Util.RuntimeOptions): DescribeVulWhitelistResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeVulWhitelist',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeVulWhitelist(request: DescribeVulWhitelistRequest): DescribeVulWhitelistResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeVulWhitelistWithOptions(request, runtime);
}

model RenewInstanceRequest {
  clientToken?: string(name='ClientToken'),
  duration?: int32(name='Duration'),
  instanceId?: string(name='InstanceId'),
  ownerId?: long(name='OwnerId'),
  pricingCycle?: string(name='PricingCycle'),
  vmNumber?: string(name='VmNumber'),
}

model RenewInstanceResponseBody = {
  orderId?: string(name='OrderId'),
  requestId?: string(name='RequestId'),
}

model RenewInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RenewInstanceResponseBody(name='body'),
}

async function renewInstanceWithOptions(request: RenewInstanceRequest, runtime: Util.RuntimeOptions): RenewInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.duration)) {
    query['Duration'] = request.duration;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.pricingCycle)) {
    query['PricingCycle'] = request.pricingCycle;
  }
  if (!Util.isUnset(request.vmNumber)) {
    query['VmNumber'] = request.vmNumber;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RenewInstance',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function renewInstance(request: RenewInstanceRequest): RenewInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return renewInstanceWithOptions(request, runtime);
}

model UpgradeInstanceRequest {
  clientToken?: string(name='ClientToken'),
  instanceId?: string(name='InstanceId'),
  ownerId?: long(name='OwnerId'),
  versionCode?: int32(name='VersionCode'),
  vmNumber?: int32(name='VmNumber'),
}

model UpgradeInstanceResponseBody = {
  orderId?: string(name='OrderId'),
  requestId?: string(name='RequestId'),
}

model UpgradeInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpgradeInstanceResponseBody(name='body'),
}

async function upgradeInstanceWithOptions(request: UpgradeInstanceRequest, runtime: Util.RuntimeOptions): UpgradeInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.versionCode)) {
    query['VersionCode'] = request.versionCode;
  }
  if (!Util.isUnset(request.vmNumber)) {
    query['VmNumber'] = request.vmNumber;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpgradeInstance',
    version = '2016-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function upgradeInstance(request: UpgradeInstanceRequest): UpgradeInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return upgradeInstanceWithOptions(request, runtime);
}

